﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Pipes.Queries.Parser;
using Pipes.Queries.Provider;

namespace Pipes.Queries.Tests
{
  [TestClass]
  public class ExpressionEvaluation
  {
    private void TestEvaulation(string statement, object expected)
    {
      var parser = new PqlParser();
      parser.Parse(statement);
      Assert.IsTrue(string.IsNullOrEmpty(parser.FailMessage));
      var provider = new Pipes.Queries.Provider.Dual.DualProvider();
      var set = provider.ExecuteQuery(parser.Script);
      var tbl = set.Tables[0];
      Assert.AreEqual(expected, tbl.Rows[0][0]);
    }

    [TestMethod]
    public void TestEval01() { TestEvaulation("select 2+2", 4m); }
  }
}
